package com.kara.webapp.components.student;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.annotations.ActivationRequestParameter;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.corelib.components.TextField;

import com.kara.entity.Student;


public class StudentForm {

  @ActivationRequestParameter
  private long studentId;

  @Property
  private Student student;
  
  @Component(id = "firstName", parameters = { "value=student.firstName", "validate=required" })
  private TextField firstName;
  
  @Component(id = "lastName", parameters = { "value=student.lastName", "validate=required" })
  private TextField lastName;
  
  @Component(id = "mobilePhone", parameters={"value=student.mobilePhone", "validate=required"})
  private TextField mobilePhone;
  
  @Component(id = "email", parameters={"value=student.email", "validate=required"})
  private TextField email;
  
  @Parameter(value = "message:button.save", defaultPrefix = BindingConstants.LITERAL)
  @Property
  private String submitLabel;
  
  
  @SetupRender
  private void setUp(){
    if (studentId == 0){
      student = new Student();
    }
  }
  Object onSuccess() {
    if (studentId == 0){
      
    }
    
    return null;
  }
}
